import {
  getThisObjCommonSetVal,
  getThisObjSetValItem,
  processEl
} from './auth'
// import { getFnInputParam } from '@/utils/hyurl'
import { getCheckRecordKeyStr } from './hyrecord'
import { getFnInputParam } from './hyurl'
import { I_APP_ID } from '@/settings'

export function changeLoadGeneralModal(thisObj, btnItem, refOpen, triggerOpenParam) {
  // changeSelectType(thisObj, refOpen)
  thisObj.formItem = btnItem
  thisObj.visible = true
  thisObj.triggerOpenParam = triggerOpenParam
  if (refOpen.refOpenTitle !== undefined) {
    thisObj.title = refOpen.refOpenTitle
  } else {
    thisObj.title = '操作信息'
  }
  thisObj.width = refOpen.refOpenWidth
  // changeModelInitWidth(thisObj, refOpen.refOpenWidth)
  const pageTempData = getLoadPageUrlData(refOpen, triggerOpenParam)
  pageTempData.refOpen = refOpen
  if (pageTempData !== null) {
    thisObj.pageUrlData = Object.assign({}, pageTempData)
  } else {
    thisObj.$message('按钮响应界面URL地址未位置')
  }
}

export function getOperatorDefVal(thisObj, refSetOpenVal) {
  if (refSetOpenVal === undefined || refSetOpenVal.length === 0) {
    return {}
  }
  const globalData = thisObj.globalData
  return getFnInputParam(thisObj, globalData, refSetOpenVal)
}

export function getBtnDefVal(thisObj, btnItem) {
  if (btnItem === undefined || btnItem === null) {
    return {}
  }
  if (btnItem.objBtn === undefined || btnItem.objBtn === null) {
    return {}
  }
  const refSetOpenVal = btnItem.objBtn.refSetOpenVal
  return getOperatorDefVal(thisObj, refSetOpenVal)
}

export function getChangeInitSrcObj(thisObj, panelEl, newInitSrcObj) {
  if (thisObj.initSrcObj.initSrcOpenWidth !== undefined) {
    panelEl.initSrcOpenWidth = thisObj.initSrcObj.initSrcOpenWidth
  }
  if (newInitSrcObj === undefined) {
    // return panelEl
    if (thisObj.initSrcObj.initSrcLabel === undefined || thisObj.initSrcObj.initSrcLabel === '') {
      // 返回默认服务
      return panelEl
    }
    if (panelEl.initSrcRefId === thisObj.initSrcObj.initSrcRefId) {
      if (thisObj.initSrcObj.initSrcLabel === undefined) {
        thisObj.initSrcObj.initSrcLabel = panelEl.initSrcLabel
      }
    }
    // 多面板组合方式,以开窗指定单选或多选为主
    return thisObj.initSrcObj
  } else {
    console.log('tab 重置服务 thisObj.initSrcObj.newInitSrcObj',newInitSrcObj)
    if (newInitSrcObj.initSrcSearch === undefined) {
      newInitSrcObj.initSrcSearch = thisObj.initSrcObj.initSrcSearch
    }
    if (newInitSrcObj.initSrcSearch === undefined) {
      newInitSrcObj.initSrcOpenWidth = thisObj.initSrcObj.initSrcOpenWidth
    }
    return newInitSrcObj
  }
}
export function getLoadPageUrlData(refOpen, triggerOpenParam) {
  let pageUrlData = {}
  if (undefined !== refOpen) {
    pageUrlData.S_PAGE_ID = refOpen.refObjPageIdIdx
    pageUrlData.S_PAGE_VER = refOpen.refObjPageVerIdx
    pageUrlData.S_PARTITION = refOpen.refObjPagePartition
    const initSrcObj = {}
    initSrcObj.initSrcLabel = refOpen.refObjFnKey
    initSrcObj.initSrcUrl = refOpen.refObjUrlKey
    initSrcObj.initSrcType = refOpen.refOpenSetType
    initSrcObj.initSrcPanelId = refOpen.refObjPanelIdx
    initSrcObj.initSrcRefId = refOpen.refTplId
    initSrcObj.initSrcOpenId = refOpen.refObjId
    initSrcObj.initSrcOpenWidth = refOpen.refOpenWidth
    pageUrlData.initSrcObj = initSrcObj
    pageUrlData.triggerOpenParam = triggerOpenParam
  } else {
    pageUrlData = null
  }
  return pageUrlData
}
export function changeSelectType(thisObj, refOpen) {
  if (refOpen.refOpenSetType !== undefined) {
    if (refOpen.refOpenSetType === 'checkbox' || refOpen.refOpenSetType === 'radio') {
      thisObj.selectType = refOpen.refOpenSetType
    }
  }
}

export function changeModelInitWidth(thisObj, refOpenWidth) {
  // if (undefined === refOpenWidth) {
  //   thisObj.width = '800px'
  //   return
  // }
  // thisObj.screenWidth = document.body.clientWidth
  // if (thisObj.screenWidth < 991) {
  //   return '95%'
  // } else if (thisObj.screenWidth < 1400) {
  //   return '90%'
  // } else {
  //   return '800px'
  // }
  // thisObj.width = (thisObj.screenWidthFix * refOpenWidth) + 'px'
}

export function changeSelectReturnData(thisObj, globalData) {
  let returnRows = []
  if (thisObj.formItem.refOpen !== undefined) {
    if (thisObj.formItem.refOpen.refSetVal !== undefined) {
      const openParam = thisObj.triggerOpenParam.openParam
      // 个性触发参数，可以时提前将参数转换未标准UI接口需的参数
      returnRows = getThisObjSetValItem(thisObj, globalData, openParam, thisObj.formItem.refOpen.refSetVal)
    } else {
      if (globalData !== undefined) {
        returnRows = globalData.tableSelectedRow
      }
    }
    const triggerRefOpenData = thisObj.formItem.refOpen.triggerRefOpenData
    if (triggerRefOpenData.refSetVal !== undefined) {
      // 标准开窗返回参数
      const openParam = thisObj.triggerOpenParam.openParam
      returnRows = getThisObjSetValItem(thisObj, globalData, openParam, triggerRefOpenData.refSetVal)
    }
  }
  return returnRows
}

export function getRefDynamicOpenObj(thisObj, refOpenObj, globalData) {
  if (refOpenObj !== null) {
    const triggerRefOpenData = refOpenObj.triggerRefOpenData
    if (triggerRefOpenData.refOpenObj === undefined || triggerRefOpenData.refOpenObj === null) {
      return refOpenObj
    }
    if (triggerRefOpenData.refOpenObj === 1) {
      return refOpenObj
    } else if (triggerRefOpenData.refOpenObj === 2) {
      // 预览效果窗口
      const refSetOpenVal = refOpenObj.refSetOpenVal
      // const param = getOpenParamData(globalData, refSetOpenVal)
      const param = getFnInputParam(thisObj, globalData, refSetOpenVal)
      if (param.refOpenType !== undefined && param.refOpenType !== '') {
        triggerRefOpenData.refObjPageIdIdx = param.refObjPageIdIdx
        triggerRefOpenData.refObjPageVerIdx = param.refObjPageVerIdx
        triggerRefOpenData.refObjPagePartition = param.refObjPagePartition
        triggerRefOpenData.refObjPanelIdx = param.refObjPanelIdx
        triggerRefOpenData.refObjId = param.refObjId
        triggerRefOpenData.refTplId = param.refTplId
        triggerRefOpenData.refOpenWidth = param.refOpenWidth
        triggerRefOpenData.refOpenType = param.refOpenType
        if (param.refObjFnKey === undefined) {
          param.refObjFnKey = 'init'
        }
        if (param.refObjUrlKey === undefined) {
          param.refObjUrlKey = 'empty'
        }
        if (param.refObjDataKey === undefined) {
          if (param.refOpenType === 'formTplModal') {
            triggerRefOpenData.refObjDataKey = 'formPanel'
          }
        }
        triggerRefOpenData.refObjFnKey = param.refObjFnKey
        triggerRefOpenData.refObjUrlKey = param.refObjUrlKey
        refOpenObj.triggerRefOpenData = triggerRefOpenData
        return refOpenObj
      } else {
        console.log('开窗数据已被清除,请联系管理员.')
        return null
      }
    } else {
      return refOpenObj
    }
  }
  return refOpenObj
}

export function getRefOpenObj(thisObj, item, globalData) {
  let refOpenObj = null
  if (undefined !== item.refOpenList) {
    const refOpenList = item.refOpenList
    for (const i in refOpenList) {
      const refObj = refOpenList[i]
      const openFnKeyList = refObj.openFnKeyList
      let openFn = true
      if (undefined !== openFnKeyList && openFnKeyList.length > 0) {
        openFn = false
        for (const fnIdx in openFnKeyList) {
          const fnObj = openFnKeyList[fnIdx]
          if (fnObj === globalData.initSrcObj.initSrcLabel) {
            openFn = true
          }
        }
        console.debug(globalData.initSrcObj, '设置开窗浏览主题', openFnKeyList)
      }
      if (!openFn) {
        continue
      }
      const objEl = refObj.objEl
      if (undefined === objEl || objEl === '' || objEl === null) {
        refOpenObj = Object.assign({}, refObj)
        break
      } else {
        const funResult = processEl(globalData.globalParam, objEl)
        if (funResult) {
          refOpenObj = Object.assign({}, refObj)
          break
        }
      }
    }
  }
  const openObj = getRefDynamicOpenObj(thisObj, refOpenObj, globalData)
  console.log('item openObj',openObj ,globalData)
  const routeQuery = getCommonRouteQuery(thisObj,openObj)
  openObj.routeQuery = routeQuery
  const triggerRefOpenData = refOpenObj.triggerRefOpenData
  refOpenObj.routeUrl = triggerRefOpenData.refTplUrl
  return openObj
}
export function getCommonRouteQuery(thisObj, refOpenObj) {

  const triggerRefOpenData = refOpenObj.triggerRefOpenData

  const query = {}
  query.refObjFnKey = triggerRefOpenData.refObjFnKey
  query.refOpenSetType = triggerRefOpenData.refOpenSetType
  query.refTplId = triggerRefOpenData.refTplId
  query.refOpenObj = triggerRefOpenData.refOpenObj
  console.log('triggerRefOpenData',triggerRefOpenData ,thisObj.globalData)
  const openParam = getFnInputParam(thisObj, thisObj.globalData, refOpenObj.refSetOpenVal)
  return Object.assign({}, query, openParam)
}

/**
 * 获取选择列表数据
 * @param thisObj
 * @param globalData
 * @param refSetOpenVal
 */
export function getSelectedTableData(thisObj, globalData, refSetOpenVal) {
  const selectRow = []
  if (refSetOpenVal === undefined || refSetOpenVal.length === 0) {
    return selectRow
  }
  const refSetOpenValLen = refSetOpenVal.length
  let selectedRows = []
  if (globalData.tableSelectedRow !== undefined) {
    selectedRows = globalData.tableSelectedRow
  }
  const rowLen = selectedRows.length
  for (let i = 0; i < rowLen; i++) {
    const rowTmpObj = selectedRows[i]
    const rowNewObj = {}
    let hasTableDataKey = false
    for (let j = 0; j < refSetOpenValLen; j++) {
      const openValObj = refSetOpenVal[j]
      if (openValObj.keyDataSet === 'tableData') {
        hasTableDataKey = true
        if (openValObj.valDataSet === 'tableSelectedRow') {
          rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, globalData, rowTmpObj, openValObj)
          // rowNewObj[openValObj.key] = getCommonSetVal(rowTmpObj, openValObj)
        } else if (openValObj.valDataSet === 'clickRow') {
          rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, globalData, globalData.clickRow, openValObj)
          // rowNewObj[openValObj.key] = getCommonSetVal(globalData.openParam, openValObj)
        } else if (openValObj.valDataSet === 'openParam') {
          rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, globalData, globalData.openParam, openValObj)
          // rowNewObj[openValObj.key] = getCommonSetVal(globalData.openParam, openValObj)
        } else if (openValObj.valDataSet === 'formModel') {
          rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, globalData, globalData.formModel, openValObj)
          // rowNewObj[openValObj.key] = getCommonSetVal(globalData.formModel, openValObj)
        } else {
          rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, globalData, globalData.globalParam, openValObj)
          // rowNewObj[openValObj.key] = getCommonSetVal(globalData.globalParam, openValObj)
        }
      }
    }
    if (hasTableDataKey) {
      selectRow.push(rowNewObj)
    }
  }
  return selectRow
}

export function getMergeSelectedRows(thisObj, openRecord, selectedRows, refSetOpenVal) {
  const selectRow = []
  if (refSetOpenVal === undefined || refSetOpenVal.length === 0) {
    return selectedRows
  }
  const refSetOpenValLen = refSetOpenVal.length
  const rowLen = selectedRows.length
  for (let i = 0; i < rowLen; i++) {
    const rowTmpObj = selectedRows[i]
    const rowNewObj = {}
    for (let j = 0; j < refSetOpenValLen; j++) {
      const openValObj = refSetOpenVal[j]
      console.log(openValObj.valDataSet, openValObj)
      if (openValObj.valDataSet === 'tableSelectedRow') {
        // rowNewObj[openValObj.key] = getCommonSetVal(rowTmpObj, openValObj)
        rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, rowTmpObj, openValObj)
      } else if (openValObj.valDataSet === 'clickRow') {
        rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, rowTmpObj, openValObj)
        // rowNewObj[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      } else if (openValObj.valDataSet === 'openParam') {
        rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
        // rowNewObj[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      } else if (openValObj.valDataSet === 'formModel') {
        rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
        // rowNewObj[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      } else {
        rowNewObj[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
        // rowNewObj[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      }
    }
    selectRow.push(rowNewObj)
  }
  return selectRow
}

export function getOpenParam(thisObj, openRecord, refSetOpenVal) {
  const openParam = {}
  if (refSetOpenVal === undefined || refSetOpenVal.length === 0) {
    return openParam
  }
  const refSetOpenValLen = refSetOpenVal.length
  const checkRecord = getCheckRecordKeyStr(thisObj.tableSelectedRow)
  for (let j = 0; j < refSetOpenValLen; j++) {
    const openValObj = refSetOpenVal[j]
    if (openValObj.keyDataSet === 'openParam' || openValObj.keyDataSet === 'formModel' || openValObj.keyDataSet === 'globalData') {
      if (openValObj.valDataSet === 'tableSelectedRow') {
        // let val = getCommonSetVal(checkRecord, openValObj)
        let val = getThisObjCommonSetVal(thisObj, thisObj.globalData, checkRecord, openValObj)
        if (val === null || val === undefined) {
          val = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
          // val = getCommonSetVal(openRecord, openValObj)
        }
        openParam[openValObj.key] = val
      } else if (openValObj.valDataSet === 'clickRow') {
        openParam[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
        // openParam[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      } else {
        openParam[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
        // openParam[openValObj.key] = getCommonSetVal(openRecord, openValObj)
      }
    } else {
      openParam[openValObj.key] = getThisObjCommonSetVal(thisObj, thisObj.globalData, openRecord, openValObj)
      // openParam[openValObj.key] = getCommonSetVal(openRecord, openValObj)
    }
  }
  // 不配置开窗参数,默认不传递
  return openParam
}

export function openLoadGeneralModal(btnItem, globalData, _thisObj) {
  const nowBtnItem = Object.assign({}, btnItem)
  if (undefined !== btnItem.refOpen) {
    const refOpen = btnItem.refOpen
    const tableData = getSelectedTableData(_thisObj, globalData, refOpen.refSetOpenVal)
    const openParam = getFnInputParam(_thisObj, globalData, refOpen.refSetOpenVal)
    // const openParam = getReqParamData(_thisObj, globalData, refOpen.refSetOpenVal)
    const defVal = getBtnDefVal(_thisObj, btnItem)
    const triggerOpenParam = {}
    if (tableData.length > 0) {
      triggerOpenParam.tableData = tableData
    }
    triggerOpenParam.tableData = tableData
    triggerOpenParam.openParam = Object.assign({}, openParam, defVal)
    triggerOpenParam.openBtnItem = btnItem

    const triggerRefOpenData = refOpen.triggerRefOpenData
    nowBtnItem.urlKey = triggerRefOpenData.refObjUrlKey
    console.log('open data', triggerOpenParam.openParam, triggerRefOpenData)
    if (triggerRefOpenData.refOpenType === 'formTplModal') {
      _thisObj.$refs.formTplModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'uiModal') {
      _thisObj.$refs.uiModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'treeNodeModal') {
      _thisObj.$refs.treeNodeModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'treeAndListModal') {
      _thisObj.$refs.treeAndListModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'listAndListModal') {
      _thisObj.$refs.listAndListModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'stepsModal') {
      _thisObj.$refs.stepsModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else if (triggerRefOpenData.refOpenType === 'echartModal') {
      _thisObj.$refs.echartModal.showLoadGeneralModal(nowBtnItem, triggerRefOpenData, triggerOpenParam)
    } else {
      _thisObj.$message.warning('模版类型不支持:' + triggerRefOpenData.refOpenType)
    }
  } else {
    // if (undefined !== btnItem.refId) {
    //   const uidata = _thisObj.uidata[btnItem.refId]
    //   _thisObj.$refs.formTplModal.showGeneralModal(btnItem, uidata, openRecord)
    // } else {
    //   console.log('openLoadGeneralModal btnItem', btnItem)
    _thisObj.$message.warning('模版类型不支持')
    // }
  }
}

export function getInitLoadUiPageUrlDataParam(thisObj) {
  const param = {}
  // param.S_PAGE_ID  ='806ce93222a44d07a4333e8953a6da61';
  // param.S_PAGE_VER ='v0.02';
  if (undefined !== thisObj.pageUrlData && thisObj.pageUrlData.S_PAGE_ID !== '') {
    // 开窗modal赋值参数
    param.S_PAGE_ID = thisObj.pageUrlData.S_PAGE_ID
    param.S_PAGE_VER = thisObj.pageUrlData.S_PAGE_VER
    param.S_PARTITION = thisObj.pageUrlData.S_PARTITION
    thisObj.initSrcObj = thisObj.pageUrlData.initSrcObj
    thisObj.triggerOpenParam = Object.assign({}, thisObj.pageUrlData.triggerOpenParam)
    thisObj.openParam = Object.assign({}, thisObj.pageUrlData.triggerOpenParam.openParam)
    if (thisObj.pageUrlData.triggerOpenParam.tableData !== undefined) {
      thisObj.tableData = thisObj.pageUrlData.triggerOpenParam.tableData
    }
    thisObj.parentRefOpen = Object.assign({}, thisObj.pageUrlData.refOpen)
  } else {
    // 其他
    param.S_PAGE_ID = thisObj.S_PAGE_ID
    param.S_PAGE_VER = thisObj.S_PAGE_VER
    param.S_PARTITION = thisObj.S_PARTITION
  }
  if (undefined === param.S_PAGE_ID) {
    // thisObj.$route 获取到旧地址
    // 开窗modal赋值参数
    param.S_PARTITION = thisObj.$route.params.S_PARTITION
    param.S_PAGE_ID = thisObj.$route.params.S_PAGE_ID
    param.S_PAGE_VER = thisObj.$route.params.S_PAGE_VER
  }
  initUiPageUrl(thisObj, param)
  param.initSrcOpenId = thisObj.initSrcObj.initSrcOpenId
  param.I_APP_ID = I_APP_ID
  return param
}

export function initUiPageUrl(thisObj, param) {
  thisObj.uiPageUrl = Object.assign({})
  thisObj.uiPageUrl.S_UI_PAGE_ID_IDX_2025 = param.S_PAGE_ID
  thisObj.uiPageUrl.S_UI_PAGE_VER_IDX_2025 = param.S_PAGE_VER
  thisObj.uiPageUrl.S_UI_PARTITION_2025 = param.S_PARTITION
}

export function getOpenLocalFormModel() {
  const refOpenObj = {}
  refOpenObj.i_OPEN_OBJ = 1030
  refOpenObj.i_OPEN_TYPE = 1
  const triggerRefOpenData = {}
  triggerRefOpenData.refObjPageIdIdx = '2179729457159'
  triggerRefOpenData.refObjPageVerIdx = 'v0.02'
  triggerRefOpenData.refObjPagePartition = '32'
  triggerRefOpenData.refObjPanelIdx = '2187748966413'
  triggerRefOpenData.refTplId = '2294049406984'
  triggerRefOpenData.refOpenWidth = '900'
  triggerRefOpenData.refOpenType = 'formTplModal'
  triggerRefOpenData.refObjDataKey = 'formPanel'
  triggerRefOpenData.refObjFnKey = 'init'
  triggerRefOpenData.refObjUrlKey = 'init'
  triggerRefOpenData.refOpenTitle = '保存表单'
  refOpenObj.triggerRefOpenData = triggerRefOpenData
  const refSetOpenVal = []
  const formData = { key: 'S_FORM_DATA', val: 'S_FORM_DATA' }
  const pageId = { key: 'S_PAGE_ID_IDX', val: 'S_PAGE_ID_IDX' }
  const pageVer = { key: 'S_PAGE_VER_IDX', val: 'S_PAGE_VER_IDX' }
  const blockTplId = { key: 'S_BLOCK_TPL_ID', val: 'S_BLOCK_TPL_ID' }
  const panelTplId = { key: 'S_PANEL_TPL_ID', val: 'S_PANEL_TPL_ID' }
  const panelTplVer = { key: 'S_PANEL_TPL_VER', val: 'S_PANEL_TPL_VER' }
  const sessionTplId = { key: 'I_SESSION_TPL_ID', val: 'I_SESSION_TPL_ID' }
  refSetOpenVal.push(formData)
  refSetOpenVal.push(pageId)
  refSetOpenVal.push(pageVer)
  refSetOpenVal.push(blockTplId)
  refSetOpenVal.push(panelTplId)
  refSetOpenVal.push(panelTplVer)
  refSetOpenVal.push(sessionTplId)
  refOpenObj.refSetOpenVal = refSetOpenVal
  return refOpenObj
}

export function getOpenLocalFormList() {
  const refOpenObj = {}
  refOpenObj.i_OPEN_OBJ = 1
  refOpenObj.i_OPEN_TYPE = 1
  const triggerRefOpenData = {}
  triggerRefOpenData.refObjPageIdIdx = '2179729457161'
  triggerRefOpenData.refObjPageVerIdx = 'v0.02'
  triggerRefOpenData.refObjPagePartition = '32'
  triggerRefOpenData.refObjPanelIdx = '2187883184135'
  triggerRefOpenData.refTplId = '2344112619531'
  triggerRefOpenData.refOpenWidth = '1000'
  triggerRefOpenData.refOpenType = 'uiModal'
  triggerRefOpenData.refObjDataKey = 'tableTplList'
  triggerRefOpenData.refObjFnKey = 'normal'
  triggerRefOpenData.refObjUrlKey = 'page'
  triggerRefOpenData.refOpenTitle = '列表管理'
  refOpenObj.triggerRefOpenData = triggerRefOpenData
  const refSetOpenVal = []
  const pageId = { key: 'S_PAGE_ID_IDX', val: 'S_PAGE_ID_IDX' }
  const pageVer = { key: 'S_PAGE_VER_IDX', val: 'S_PAGE_VER_IDX' }
  const panelTplId = { key: 'S_PANEL_TPL_ID', val: 'S_PANEL_TPL_ID' }
  const panelTplVer = { key: 'S_PANEL_TPL_VER', val: 'S_PANEL_TPL_VER' }
  refSetOpenVal.push(pageId)
  refSetOpenVal.push(pageVer)
  refSetOpenVal.push(panelTplId)
  refSetOpenVal.push(panelTplVer)
  refOpenObj.refSetOpenVal = refSetOpenVal
  return refOpenObj
}

export function getOpenLocalSessionTplList() {
  const refOpenObj = {}
  refOpenObj.i_OPEN_OBJ = 1
  refOpenObj.i_OPEN_TYPE = 1
  const triggerRefOpenData = {}
  triggerRefOpenData.refObjPageIdIdx = '2185567928321'
  triggerRefOpenData.refObjPageVerIdx = 'v0.02'
  triggerRefOpenData.refObjPagePartition = '32'
  triggerRefOpenData.refObjPanelIdx = '2287674064909'
  // triggerRefOpenData.refTplId = '2347535171584'
  triggerRefOpenData.refTplId = '2347535171584'
  triggerRefOpenData.refOpenWidth = '1000'
  triggerRefOpenData.refOpenType = 'uiModal'
  triggerRefOpenData.refObjDataKey = 'tableTplList'
  triggerRefOpenData.refObjFnKey = 'sessionNormal'
  triggerRefOpenData.refObjUrlKey = 'page'
  triggerRefOpenData.refOpenTitle = '定制模板'
  refOpenObj.triggerRefOpenData = triggerRefOpenData
  const refSetOpenVal = []
  const pageId = { key: 'S_PAGE_ID_IDX', val: 'S_PAGE_ID_IDX' }
  const pageVer = { key: 'S_PAGE_VER_IDX', val: 'S_PAGE_VER_IDX' }
  const panelTplId = { key: 'S_PANEL_TPL_ID', val: 'S_PANEL_TPL_ID' }
  const panelTplVer = { key: 'S_PANEL_TPL_VER', val: 'S_PANEL_TPL_VER' }
  const formBlockTplId = { key: 'S_FORM_BLOCK_TPL_ID', val: 'S_FORM_BLOCK_TPL_ID' }
  const listBlockTplId = { key: 'S_LIST_BLOCK_TPL_ID', val: 'S_LIST_BLOCK_TPL_ID' }
  const btnBlockTplId = { key: 'S_BTN_BLOCK_TPL_ID', val: 'S_BTN_BLOCK_TPL_ID' }
  const openUi = { key: 'openUi', val: 'openUi' }
  refSetOpenVal.push(pageId)
  refSetOpenVal.push(pageVer)
  refSetOpenVal.push(panelTplId)
  refSetOpenVal.push(panelTplVer)
  refSetOpenVal.push(formBlockTplId)
  refSetOpenVal.push(listBlockTplId)
  refSetOpenVal.push(btnBlockTplId)
  refSetOpenVal.push(openUi)
  refOpenObj.refSetOpenVal = refSetOpenVal
  return refOpenObj
}
